//      suffix_array.h
//      
//      Copyright 2012 tqlong <tqlong@espada>
//      
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 2 of the License, or
//      (at your option) any later version.
//      
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//      
//      You should have received a copy of the GNU General Public License
//      along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.

#ifndef LIB_DIV_SUF_SORT_WRAPPER_H
#define LIB_DIV_SUF_SORT_WRAPPER_H
#include <string>
#include <vector>
#include <divsufsort.h>

class sastring : public std::string 
{
 public:
  sastring(const std::string& s);
  sastring(const sastring& s);
  sastring();
  ~sastring();

  sastring& operator=(const std::string& s);
  sastring& operator=(const sastring& s);
  
  void sasearch(const std::string& p, int& left, int& size) const;

  static int pattern_count(const std::vector<sastring>& SAVEC, const std::string& p, int periodic, uint frame);
  static std::vector<int> pattern_count(const std::vector<sastring>& SAVEC, const std::string& p, int periodic);
 public:
  sauchar_t *T;
  saidx_t *SA;
  saint_t result;
 protected:
  void build_sa();
  static void str2sachar(const std::string& s, sauchar_t** T);		
  void copy_pointer(const sastring& s);
};

typedef std::vector<std::string> sastring_vec_t;



#endif
